home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 3.6 KB | 117 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- package mixer.mc;
-
- import mixer.display.*;
-
- import quicktime.std.movies.*;
- import quicktime.std.movies.media.*;
- import quicktime.app.audio.*;
- import quicktime.app.players.*;
- import quicktime.*;
- import quicktime.std.*;
- import java.util.*;
-
- import javax.swing.*;
- import java.awt.*;
-
- /** This is the first class involved in making the mixer. It is capable of making the
- * JComponent for the master control of the movie.
- */
- public class MixerMovie implements MixerComponents {
- private Vector audioMedia;
- private AudioSpec master;
-
- /** This constructor will create a Mixer for a movie in a QTPlayer.
- * @param pl the QTPlayer with the movie to mix
- * The assumption is that the Player will serve as the master control for the movie
- */
- public MixerMovie (QTPlayer pl) throws QTException {
- this (pl.getMovieController().getMovie(), pl);
- }
-
- /** This constructor will create a Mixer for a movie in a MoviePlayer.
- * @param pl the MoviePlayer with the movie to mix
- * The assumption is that the Player will serve as the master control for the movie
- */
- public MixerMovie (MoviePlayer pl) throws QTException {
- this (pl.getMovie(), pl);
- }
-
- private MixerMovie (Movie m, AudioSpec mast) throws QTException {
- master = mast;
- m.preroll (0, 1.0F);
- audioMedia = getAudioTracks (m);
- }
-
-
- /** This method will return the master control for the movie.
- * @return the AudioSpec object that serves as the master control for the movie
- */
- public AudioSpec getMaster() {
- return master;
- }
-
- /** This method returns all of the MixerComponents that are contained inside of
- * the movie.
- * @return the array of MixerComponents found in the movie
- */
- public MixerComponents[] getChannels() {
- if (audioMedia == null)
- return null;
- MixerComponents[] ar = new MixerComponents [audioMedia.size()];
- for (int i = 0; i < ar.length; i++)
- ar[i] = (MixerComponents)audioMedia.elementAt(i);
- return ar;
- }
-
- /** This method creates the component that needs to be given to the user to edit
- * the channels in this movie.
- * @return the component with the controls necessary to mix the channels
- */
- public JComponent makeEditComponent () throws QTException {
- JPanel balance = new JPanel ();
- balance.setLayout (new BorderLayout());
- balance.add (new SoloableChannels (getChannels()), "Center");
- balance.add (new Label ("Tracks"), "North");
- return balance;
- }
-
- /** Returns whether or not this movie contains tracks which are editable. This
- * should be true if there are any movie or sound tracks in the movie
- * @return the editable state of the movie
- */
- public boolean isEditable() {
- return getChannels() != null;
- }
-
- /* This method gets all of the audio tracks out of a movie. */
- private static Vector getAudioTracks (Movie mov) throws QTException {
- int numTracks = mov.getTrackCount();
- Vector v = new Vector(numTracks);
- Track curTrack;
- Media trackMedia;
-
- // add the audio media from each track
- for (int i = 1; i <= numTracks; i++) {
- curTrack = mov.getIndTrack(i);
- trackMedia = Media.getTrackMedia(curTrack);
- if (trackMedia instanceof SoundMedia)
- v.addElement(new MixerSoundTrack ((SoundMedia) trackMedia));
- else if (trackMedia instanceof MusicMedia)
- v.addElement(new MixerMusicTrack (mov, (MusicMedia) trackMedia));
- }
-
- if (v.size() == 0)
- return null;
-
- v.setSize (v.size());
- return v;
- }
- }
-